//
//  ZYCTeachingTeachLearningDetailHeaderView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/31.
//

#import "ZYCTeachingTeachLearningDetailHeaderView.h"
#import "ZYCTeachLearningPaperModel.h"
#import "ZYCTeachLearningDetailModel.h"

@interface ZYCTeachingTeachLearningDetailHeaderView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *placeHolderLabel;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *contentLabel;

@end
@implementation ZYCTeachingTeachLearningDetailHeaderView

- (void)setDModel:(ZYCTeachLearningDetailModel *)dModel{
    _dModel = dModel;
    _titleLabel.text = dModel.evaluateTitle;
    _timeLabel.text = dModel.createTime;
    _nameLabel.text = dModel.createBy;
    NSInteger status = [dModel.publishStatus integerValue];
    if(status == 2){
        _statusLabel.text = @"进行中";
        _statusLabel.backgroundColor = HEX_RGB(@"#39A85B");
    }else{
        _statusLabel.text = @"已结束";
        _statusLabel.backgroundColor = HEX_RGB(@"#B9B9B9");
    }
    _contentLabel.text = dModel.remark;
    

}

- (void)setModel:(ZYCTeachLearningPaperModel *)model{
    _model = model;
    _titleLabel.text = model.evaluateTitle;
    _timeLabel.text = model.createTime;
    _nameLabel.text = model.createBy;
    NSInteger status = [model.publishStatus integerValue];
    if(status == 2){
        _statusLabel.text = @"进行中";
        _statusLabel.backgroundColor = HEX_RGB(@"#39A85B");
    }else{
        _statusLabel.text = @"已结束";
        _statusLabel.backgroundColor = HEX_RGB(@"#B9B9B9");
    }
    _contentLabel.text = model.remark;
    
}



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"FFFFFF");
        [self addSubview:self.titleLabel];
        [self addSubview:self.timeLabel];
        [self addSubview:self.nameLabel];
        [self addSubview:self.statusLabel];
        [self addSubview:self.bgView];
        [self addSubview:self.placeHolderLabel];
        [self addSubview:self.nameLabel];
        [self addSubview:self.line];
        [self addSubview:self.contentLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(13.5f);
            make.right.equalTo(self).offset(-13.5f);
            make.top.equalTo(self).offset(14.5f);
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(15.5f);
        }];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.timeLabel.mas_right).offset(24.0f);
            make.centerY.equalTo(self.timeLabel);
        }];
        
        [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-10.0f);
            make.centerY.equalTo(self.timeLabel);
            make.size.mas_equalTo(CGSizeMake(56.0f, 23.0f));
        }];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self);
            make.top.equalTo(self.statusLabel.mas_bottom).offset(16.0f);
            make.height.mas_equalTo(5.0f);
        }];
        
        [self.placeHolderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel);
            make.top.equalTo(self.bgView.mas_bottom).offset(14.5f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(13.5f);
            make.right.equalTo(self).offset(-13.5f);
            make.top.equalTo(self.placeHolderLabel.mas_bottom).offset(15.0f);
            make.height.mas_equalTo(0.5f);
        }];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(13.5f);
            make.right.equalTo(self).offset(-13.5f);
            make.top.equalTo(self.line.mas_bottom).offset(16.5f);
            make.bottom.equalTo(self).offset(-10.0f);
        }];
        
//        [self layoutIfNeeded];

    }
    return self;
}


- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
        _titleLabel.numberOfLines = 0;
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _timeLabel;
}


- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _nameLabel;
}


- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.textColor = HEX_RGB(@"FFFFFF");
        _statusLabel.font = kCustomFont(@"PingFangSC-Light", 12.0f);
        _statusLabel.textAlignment = NSTextAlignmentCenter;
        _statusLabel.layer.cornerRadius = 11.5;
        _statusLabel.layer.masksToBounds = YES;
    }
    return _statusLabel;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(@"#F9F9F9");
    }
    return _bgView;
}

- (UILabel *)placeHolderLabel {
    if (!_placeHolderLabel) {
        _placeHolderLabel = [UILabel LabelWithString:@"问卷说明:" Font:kCustomFont(@"PingFangSC-Light", 16.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _placeHolderLabel;
}

- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EBEBEB");
    }
    return _line;
}


- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 16) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}
@end
